import unittest

from framework.core.crawler_result import Result


class ResultTestCase(unittest.TestCase):
    def test_1(self):
        r = Result.create(source_url="www.baidu.com", A=123, B="SCD", C=[456], D=[1, 2, 3], E=["A", "B", 3, "C"])
        self.assertEqual(123, r.get_item("A"))
        self.assertEqual("SCD", r.get_item("B"))
        self.assertEqual([456], r.get_item("C"))
        # self.assertEqual(456, r.get_item("C", merge_str=True))
        self.assertEqual([1, 2, 3], r.get_item("D"))
        # self.assertEqual("123", r.get_item("D", merge_str=True))
        self.assertEqual(["A", "B", 3, "C"], r.get_item("E"))

    def test_2(self):
        r = Result.create(source_url="www.baidu.com", A=123, B="SCD", C=[456], D=[1, 2, 3], E=["A", "B", 3, "C"])
        r.put_tags({"Key1": "A", "key2": "B"})
        self.assertEqual(r.tags["Key1"], "A")
        pass


if __name__ == '__main__':
    unittest.main()
